'use strict';

var mongoose = require('mongoose'),
    Schema = mongoose.Schema,
    baseController = require('../../../Base/server/controllers/BaseDoc.js');

var newModel = baseController.getBaseDocFields();

//待转区
newModel.WareHouse = {
    type: Schema.ObjectId,
    ref: 'WareHouse',
    required: '请输入仓库'
};
//容器
newModel.Container = {
    type: Schema.ObjectId,
    ref: 'Container',
    required: '请输入容器'
};
//状态 0:待配送 1:配送中 2:已配送
newModel.Status = {
    type: Number
};
//要货部门
newModel.DemandDepartment = {
    type: Schema.ObjectId,
    ref: 'Department'
};
//配送数量
newModel.Qty = {
    type: Number
};
//备货时间
newModel.ReadyTime = {
    type: Date
};
//备货人
newModel.StockPerson = {
    type: Schema.ObjectId,
    ref: 'User'
};
//接收数量
newModel.ReceiveQty = {
    type: Number
};
//接收时间
newModel.ReceiveTime = {
    type: Date
};
//接收人
newModel.ReceivePerson = {
    type: Schema.ObjectId,
    ref: 'User'
};

var newSchema = new Schema(newModel);
newSchema.index({WareHouse: 1, Container: 1});
newSchema.index({WareHouse: 1});

mongoose.model('DeliveryRecord', newSchema, 'DeliveryRecord');
